package com.example.permissionservice.mapper;

import com.example.permissionservice.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;

import java.util.Optional;

@Mapper
public interface RoleMapper {

    @Select("SELECT * FROM roles WHERE role_id = #{roleId}")
    Optional<Role> findById(Integer roleId);

    @Select("SELECT * FROM roles WHERE role_code = #{roleCode}")
    Optional<Role> findByRoleCode(String roleCode);

    @Insert("INSERT INTO roles(role_id, role_code) VALUES(#{roleId}, #{roleCode})")
    void save(Role role);
} 